<template>
	<!-- 弹框开始 -->
	<uni-popup ref="popup" type="bottom" :showPopup="true">
		<view class="like">
			<view class="like-tittle">
				将为您推荐适合当前人数的产品
				<i class="iconfont icon-searchclose" @click="close" />
			</view>
			<view class="like-desc">
				<view class="like-desc-box">
					<view class="like-desc-box-t">
						<image class="like-desc-box-t-img" src="@/static/img/man.png" mode="aspectFill"></image>
						人数：{{paramObj.stock}}人
					</view>
				</view>

				<!-- 购物车 -->
				<view class="cart-wrapper">
					<view class="cart-item" >
						<view class="cart-item-left">
							<view class="spec-text">请选择人数</view>
						</view>
						<view class="cart-item-right">
							<view class="stepper">
								<button class="btn minus" :disabled="paramObj.stock <= 1"
									@click="changeQuantity(-1)">-</button>
								<input class="input" type="number" v-model.number="paramObj.stock"
									 />
									 <!-- @blur="validateQuantity(index)" -->
								<button class="btn plus" :disabled="paramObj.stock >= 20"
									@click="changeQuantity(1)">+</button>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 底部操作栏 -->
			<view class="footer">
				<button class="add-cart-btn btn-class" @click="addToCart">确认并查询</button>
			</view>
		</view>
	</uni-popup>
</template>
<script>
	import {
		mapGetters
	} from 'vuex'
	export default {
		components: {},
		data() {
			return {
				imgUrl: this.$apiFun.imgUrl,
				host: this.$apiFun.host,
				paramObj: {
					page: 1,
					pageSize: 10,
					name: '',
					orderBy: '',
					stock:0,
				},
			}
		},
		computed: {
			...mapGetters([
				'addrObj'
			]),
		},
		mounted() {
		},
		methods: {
			changeQuantity(val){
				
				this.paramObj.stock = Number(this.paramObj.stock)+val
			},
			open(val) {
				this.paramObj.stock = val.stock?val.stock:0
				this.$refs.popup.open()
			},
			close() {
				this.$refs.popup.close()
			},
			addToCart(){
				this.$refs.popup.close()
				this.$emit('addToCart',this.paramObj.stock)
			}
		},
		onReachBottom() {

		},

	}
</script>

<style scoped lang="less">
	// 置顶弹框
	.like {
		width: 100%;
		background-color: #FFFFFF;
		border-radius: 20rpx 20rpx 0 0;
		padding: 0 40rpx 40rpx;
		box-sizing: border-box;

		.like-tittle {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			font-size: 34rpx;
			color: #131313;
			justify-content: space-between;
			display: flex;
			align-items: center;

			.iconfont {
				font-size: 40rpx;
			}
		}

		.like-desc {
			min-height: 400rpx;
			font-size: 25rpx;
			color: #5c5c5c;
			margin: 0 auto 40rpx;
			text-align: left;

			.like-desc-box {
				margin-bottom: 75rpx;

				.like-desc-box-t {
					font-size: 30rpx;
					color: #333333;
					display: flex;
					align-items: center;
					.like-desc-box-t-img {
						width: 36rpx;
						height: 36rpx;
					}
				}

				.like-desc-box-b {
					font-size: 26rpx;
					margin-top: 27rpx;
					color: #85898c;
				}
			}

			.cart-wrapper {
				margin: 30rpx 0 120rpx;
				background-color: #f6f5f5;
				border-radius: 10rpx;
				padding: 20rpx 30rpx;
				box-sizing: border-box;
				.cart-item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					
					.cart-item-left {
						.spec-text {
							display: block;
							font-size: 28rpx;
							color: #333;
						}

						.cart-item-left-info {
							display: flex;
							align-items: center;
							color: #9b999a;
							font-size: 20rpx;

							.price {
								padding-right: 10rpx;
								margin-right: 10rpx;
								border-right: 1rpx solid #9b999a;
								height: 14rpx;
								line-height: 14rpx;
							}

							.sum {}
						}
					}

					.cart-item-right {
						text-align: right;

						.stepper {
							display: flex;
							align-items: center;
							margin-bottom: 12rpx;

							.btn {
								width: 50rpx;
								height: 50rpx;
								line-height: 46rpx;
								padding: 0;
								// border: 2rpx solid #ddd;
								border-radius: 8rpx;
								font-size: 32rpx;
								background: white;

								&.disabled {
									opacity: 0.6;
								}
							}

							.input {
								width: 80rpx;
								height: 50rpx;
								margin: 0 12rpx;
								text-align: center;
								font-size: 28rpx;
								border: 2rpx solid #ddd;
								border-radius: 8rpx;
							}
						}

						.total {
							font-size: 28rpx;
							color: #ff4444;
						}
					}
				}
			}
		}

	.footer {
		position: fixed;
		bottom: 120rpx;
		left: 0;
		right: 0;
background-color: rgba(255, 255, 255, 0.1);
		padding: 20rpx;

		.add-cart-btn {
			background: #ff5000;
			color: #fff;
			border-radius: 50rpx;
		}
	}
	}
</style>